import request from '@/utils/request';

/**
 * 店铺列表
 */
export async function getActivityOrgListService(data) {
  return request({
    url: '/product/product/activityOrg/list',
    method: 'POST',
    unNeedToken: true,
    data: data,
  });
}

/**
 * 店铺详情
 */
export async function getActivityOrgInfoService(data) {
  const { orgId, lat, lon } = data;
  let url = '/product/product/activityOrg/info?orgId=' + orgId;
  if (lat || lon) {
    url += '&lat=' + lat + '&lon=' + lon;
  }
  return request({
    url,
    method: 'GET',
  });
}

/**
 * 店铺商品分组标签
 */
export async function getOrgGroupListService(data) {
  return request({
    url: '/product/product/takeWay/getGroup',
    method: 'POST',
    data: data,
  });
}

/**
 * 根据标签查找商品
 */
export async function getProductByGroupService(data) {
  return request({
    url: '/product/product/takeWay/getProductByGroup',
    method: 'POST',
    data: data,
  });
}

/**
 * 折扣店铺商品分组标签
 */
export async function getOrgDiscountGroupListService(data) {
  return request({
    url: '/product/product/takeWay/getDiscountGroup',
    method: 'POST',
    data: data,
  });
}

/**
 * 折扣根据标签查找商品
 */
export async function getDiscountProductByGroupService(data) {
  return request({
    url: '/product/product/takeWay/getDiscountProduct',
    method: 'POST',
    data: data,
  });
}

/**
 * 外卖查询购物车商品列表
 */
export async function getProductCarListService(data) {
  return request({
    url: '/product/v1/product/productCar/getProductCarList',
    method: 'POST',
    data: data,
  });
}

/**
 * 商品加入购物车
 */
export async function addProductToCarService(data) {
  return request({
    url: '/product/v1/product/productCar/addProduct',
    method: 'POST',
    data: data,
  });
}

// 获取店铺分类
export async function storeCategoryServer(data) {
  return request({
    url: `/product/product/getStoreCategory`,
    method: 'GET',
    data,
  });
}

/**
 * 获取外卖店铺分组和商品
 */
export async function getDiscountProductTotalServer(data) {
  return request({
    url: '/product/product/takeWay/getDiscountProductTotal',
    method: 'POST',
    data: data,
  });
}

/**
 * 获取外卖商品详情
 */
export async function getProductDetailServer(data) {
  const { releasedId } = data;
  return request({
    url: '/product/product/takeWay/getProductDetail?releasedId=' + releasedId,
    method: 'GET',
  });
}
